<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="title">#{aqarMsgs.Aqarat_Payment_Payments_PageTitle}</ui:define>
		<ui:define name="manuBar">
			<ui:include src="/controlling/aqarat/aqaratMenu.xhtml" />
		</ui:define>
		<ui:define name="content">
			<p:panel header="Payments">
				<h:form id="pay_frm">
					<p:messages id="msgs" />
					<p:panel>
						<h:panelGrid columns="6">
							<h:outputText value="#{aqarMsgs.Aqarat_Customer_ChooseCustomer}" />
							<p:autoComplete
								value="#{paymentsBean.paymentResultSet.customerId}"
								completeMethod="#{paymentsBean.searchCustomer}" var="cust"
								itemLabel="#{cust.name}" itemValue="#{cust.recid}"
								forceSelection="true">

								<f:facet name="itemtip">
									<h:panelGrid columns="3" cellpadding="5">

										<h:outputText value="#{aqarMsgs.Aqarat_Customer_Name}" />
										<h:outputText value=":" />
										<h:outputText value="#{cust.name}" />

										<h:outputText value="#{aqarMsgs.Aqarat_Customer_Mobile}" />
										<h:outputText value=":" />
										<h:outputText value="#{cust.mobile}" />

										<h:outputText value="#{aqarMsgs.Aqarat_Customer_CardNo}" />
										<h:outputText value=":" />
										<h:outputText value="#{cust.cardNo}" />
									</h:panelGrid>
								</f:facet>

							</p:autoComplete>

							<h:outputText value="#{aqarMsgs.Aqarat_Payment_DateFrom}" />
							<p:calendar value="#{paymentsBean.paymentResultSet.dateFrom}"
								pattern="dd/MM/yyyy" />

							<h:outputText value="#{aqarMsgs.Aqarat_Payment_DateTo}" />
							<p:calendar value="#{paymentsBean.paymentResultSet.dateTo}"
								pattern="dd/MM/yyyy" />
						</h:panelGrid>
						<p:commandButton value="#{aqarMsgs.Aqarat_General_Search}"
							actionListener="#{paymentsBean.searchPayments}"
							update="payments_list msgs" />
					</p:panel>
					<p:panel id="payments_list">
						<p:dataTable var="pay" id="payments_tb_list"
							value="#{paymentsBean.paymentResultSetList}" paginator="true"
							rows="10"
							paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
							rowsPerPageTemplate="5,10,15,20,25" lazy="true">

							<p:column>
								<f:facet name="header">
									<h:outputText value="#{aqarMsgs.Aqarat_Payment_Money}" />
								</f:facet>
								<h:outputText value="#{pay.money}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{aqarMsgs.Aqarat_Payment_PaymentDate}" />
								</f:facet>
								<h:outputText value="#{pay.paymentDate}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{aqarMsgs.Aqarat_Customer_Name}" />
								</f:facet>
								<h:outputText value="#{pay.customerName}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="#{aqarMsgs.Aqarat_Payment_Status}" />
								</f:facet>
								<h:outputText value="#{pay.paymentStatus}" />
							</p:column>
							<p:column exportable="false"
								headerText="#{aqarMsgs.Aqarat_General_Options}">
								<p:commandButton value="#{aqarMsgs.Aqarat_Payment_Payments_Pay}"
									update=":pay_frm:display" oncomplete="ConfirmPay.show();"
									ajax="true" actionListener="#{paymentsBean.prepareToPay}"
									rendered="#{pay.paymentStatusId ==8}">
									<f:setPropertyActionListener
										target="#{paymentsBean.selectedPaymentResultSet}"
										value="#{pay}" />
								</p:commandButton>
							</p:column>
							<f:facet name="footer">
							<h:commandLink>
								<p:graphicImage value="/resources/images/excel.png"
									style="border:0px;" alt="all Payments" />
								<p:dataExporter type="xls" target="payments_tb_list"
									fileName="Payments" />
							</h:commandLink>
						</f:facet>
						</p:dataTable>
					</p:panel>
					<p:confirmDialog widgetVar="ConfirmPay"
						message="#{aqarMsgs.Aqarat_Payment_ConfirmDialogHeader}">
						<h:panelGroup id="display">
							<p:commandButton value="#{aqarMsgs.Aqarat_General_Yes}"
								actionListener="#{paymentsBean.payApayment}"
								onstart="waiteDialog.show();"
								oncomplete="waiteDialog.hide();ConfirmPay.hide();"
								update="payments_list" />
							<p:commandButton value="#{aqarMsgs.Aqarat_General_No}"
								onclick="ConfirmPay.hide();" />
						</h:panelGroup>
					</p:confirmDialog>
				</h:form>
			</p:panel>
		</ui:define>
	</ui:composition>
</body>
</html>
